<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>DLC Search Engine: src/main/java/DataAccess/dbmanager/PostgreDBManager.java Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">DLC Search Engine
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Packages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">src/main/java/DataAccess/dbmanager/PostgreDBManager.java</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_postgre_d_b_manager_8java.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a><a class="code" href="namespacedataaccess_1_1dbmanager.html">00001</a> <span class="keyword">package </span>dataaccess.dbmanager;
<a name="l00002"></a>00002 
<a name="l00003"></a>00003 <span class="keyword">import</span> java.sql.Connection;
<a name="l00004"></a>00004 <span class="keyword">import</span> java.sql.DriverManager;
<a name="l00005"></a>00005 <span class="keyword">import</span> java.sql.SQLException;
<a name="l00006"></a>00006 
<a name="l00011"></a><a class="code" href="classdataaccess_1_1dbmanager_1_1_postgre_d_b_manager.html">00011</a> <span class="keyword">public</span> <span class="keyword">class </span><a class="code" href="classdataaccess_1_1dbmanager_1_1_postgre_d_b_manager.html">PostgreDBManager</a> {
<a name="l00012"></a>00012 
<a name="l00016"></a>00016     <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String DBURL = <span class="stringliteral">&quot;jdbc:postgresql://localhost:5432/SearchEngineDB&quot;</span>;
<a name="l00020"></a>00020     <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String DRIVER = <span class="stringliteral">&quot;org.postgresql.Driver&quot;</span>;
<a name="l00024"></a>00024     <span class="keyword">private</span> <span class="keyword">static</span> String usuario = <span class="stringliteral">&quot;postgres&quot;</span>;
<a name="l00028"></a>00028     <span class="keyword">private</span> <span class="keyword">static</span> String contrasenia = <span class="stringliteral">&quot;dlc2012&quot;</span>;
<a name="l00032"></a>00032     <span class="keyword">private</span> <span class="keyword">static</span> Connection con = null;
<a name="l00033"></a>00033 
<a name="l00037"></a><a class="code" href="classdataaccess_1_1dbmanager_1_1_postgre_d_b_manager.html#a1f08589b938029b7e2c0fac3080f651e">00037</a>     <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">synchronized</span> Connection <a class="code" href="classdataaccess_1_1dbmanager_1_1_postgre_d_b_manager.html#a1f08589b938029b7e2c0fac3080f651e">getConnection</a>() {
<a name="l00038"></a>00038         <span class="keywordflow">try</span> {
<a name="l00039"></a>00039             <span class="keywordflow">if</span> (con == null || con.isClosed()) {
<a name="l00040"></a>00040                 crearConnection();
<a name="l00041"></a>00041             }
<a name="l00042"></a>00042         } <span class="keywordflow">catch</span> (SQLException ex) {
<a name="l00043"></a>00043         }
<a name="l00044"></a>00044         <span class="keywordflow">return</span> con;
<a name="l00045"></a>00045     }
<a name="l00046"></a>00046 
<a name="l00050"></a>00050     <span class="keyword">private</span> <span class="keyword">static</span> <span class="keywordtype">void</span> crearConnection() {
<a name="l00051"></a>00051         <span class="keywordflow">try</span> {
<a name="l00052"></a>00052             Class.forName(DRIVER);
<a name="l00053"></a>00053         } <span class="keywordflow">catch</span> (ClassNotFoundException ex) {
<a name="l00054"></a>00054             System.exit(2);
<a name="l00055"></a>00055         }
<a name="l00056"></a>00056         <span class="keywordflow">try</span> {
<a name="l00057"></a>00057             con = DriverManager.getConnection(DBURL, usuario, contrasenia);
<a name="l00058"></a>00058         } <span class="keywordflow">catch</span> (SQLException ex) {
<a name="l00059"></a>00059         }
<a name="l00060"></a>00060     }
<a name="l00061"></a>00061 }
</pre></div></div><!-- contents -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Thu Feb 16 2012 02:45:40 for DLC Search Engine by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>

</body>
</html>
